#include <iostream>

using std::cout;
using std::endl;

void test()
{
    int a[5]={1, 2, 3, 4, 5};
    int *p1 = a;
    printf("%p, %p\n", a, a + 1);//一个基本单位int
    int *ptr= (int *)(&a + 1);//一个基本单位,int[5],20字节
    printf("%d,%d\n",*(a+1), *(ptr - 1));

    //a的类型是什么,int *   int[]
    //&a的类型是什么 int (*)[5]
    // + 1的作用或者效果是什么
    int *pp = a;
    /* int *pp2 = &a; */
    int (*pArr)[5] = &a;
    /* &(a + 1); //error */
    int *p2 = (a + 1);
    &p2;
    int aa = 3;
    int bb = 4;
    int cc = aa + bb;
    &cc;//ok
    /* &(aa + bb);//error */

}

void test2()
{
    //指针pInt的类型是什么：int *
    //指针pInt指向的变量的类型是什么:int
    //不同类型的指针的大小是多少:只与系统相关
    int number = 10;
    int *pInt = &number;//int 4
    char *pc;//char 1 
    short *ps;//short 2
    long *pl;//long 8
    cout << "sizeof(pc) = " << sizeof(pc) << endl;
    cout << "sizeof(ps) = " << sizeof(ps) << endl;
    cout << "sizeof(pInt) = " << sizeof(pInt) << endl;
    cout << "sizeof(pl) = " << sizeof(pl) << endl;

    int arr[10] = {1, 2, 3, 4};
    int *parr0 = (int *)((char *)&arr);//
    int *parr = (int *)((char *)&arr + 1);//
    int *parr2 = (int *)((int *)&arr + 1);//
    int *parr3 = (int *)((long *)&arr + 1);//

    printf("parr0 = %p\n", parr0);
    printf("parr = %p\n", parr);
    printf("parr2 = %p\n", parr2);
    printf("parr3 = %p\n", parr3);
}

int main()
{
    test2();
    return 0;

}
